updating oE peek4s

peek4s

<built-in> function peek4s(object addr_n_length) 

fetches a signed double words, or some signed double words, from an address in memory.

Parameters:
  1. addr_n_length : an object, either of
    • an atom addr -- to fetch one double word at addr, or
    • a pair { addr, len } -- to fetch len double words at addr
Returns:

An object, either an atom if the input was a single address, or a sequence of atoms if a sequence was passed. In both cases, atoms returned are double words, in the range -(231)..231-1.

Errors:

Peeking in memory you don't own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.

When supplying a {address, count} sequence, the count must not be negative.

Comments:

Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.

It is faster to read several double words at once using the second form of peek than it is to read one double word at a time in a loop. The returned sequence has the length you asked for on input.

Remember that peek4s takes just one argument, which in the second form is actually a 2-element sequence.

The only difference between peek4s and peek4u is how double words with the highest bit set are returned. peek4s assumes them to be negative, while peek4u just assumes them to be large and positive.

Example 1:
-- The following are equivalent: 
-- first way 
s = {peek4s(100), peek4s(104), peek4s(108), peek4s(112)} 
 
-- second way 
s = peek4s({100, 4}) 
See Also:

Using Data Double Words, poke4, peeks, peek4u, allocate, free, peek2s

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu